package com.luboyan.CBillbill.util;

/**
 * 结果封装类
 * @param <T>
 */
public class Result<T> {
    private String code;

    private String msg;

    private  T data;

    public Result(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public Result(T data){
        code = "200";
        msg = "success";
        this.data = data;
    }

    public static Result<String> success(){
        return new Result<>(null);
    }

    public static Result<String> success(String data){
        return new Result<>(data);
    }

    public static Result<String> fail(){
        return new Result<>("500", "fail");
    }

    public static Result<String> fail(String code, String msg){
        return new Result<>(code, msg);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
